/**
 * Created by NAT on 2018-02-27.
 */
/*病人详情 */
//预约列表 tab切换
$('.bespeak_change_list_actve').on('click', function () {
    var thisIndex = $(this).index();
    $(this).addClass("active_bgc").siblings().removeClass("active_bgc");
    $('.js_tabcnt').eq(thisIndex).removeClass('hidden').siblings(".js_tabcnt").addClass('hidden');
})
//就诊信息
function searchPatient() {
    var _datas = {
        patientId: patientData.patientId
    }
    if ($.trim($('.selDatepatient .selstart').val()) != '') {
        _datas.startDate = $.trim($('.selDatepatient .selstart').val())
    }
    if ($.trim($('.selDatepatient .selend').val()) != '') {
        _datas.endDate = $.trim($('.selDatepatient .selend').val())
    }
    patientSel.settings()[0].ajax.data = _datas;
    patientSel.ajData.userPhone = $.session.get("patientsUserPhone");
    patientSel.ajax.reload();
}
//收费信息
function searchOrder() {
    var _datas = {
        patientId: patientData.patientId,
        orderState: $('.js_orderstatus').val()
    }
    if ($.trim($('.selDateorder .selstart').val()) != '') {
        _datas.startDate = $.trim($('.selDateorder .selstart').val())
    }
    if ($.trim($('.selDateorder .selend').val()) != '') {
        _datas.endDate = $.trim($('.selDateorder .selend').val())
    }

    baseFn.objDelElm(orderListDTdata, 'limit')
    for (var i in _datas) {
        orderListDTdata[i] = _datas[i]
    }
    orderListDT.ajax.reload();
}
$('.js_orderstatus').val(0)
$('.js_orderstatus').on('change', function () {
    searchOrder()
})
//预约信息
function searchBooking() {
    var _datas = {
        patientId: patientData.patientId,
        userId: patientData.userId,
        bookingStatus: $('.js_bookingstatus').val()
    }
    if ($.trim($('.selDatebooking .selstart').val()) != '') {
        _datas.startDate = $.trim($('.selDatebooking .selstart').val())
    }
    if ($.trim($('.selDatebooking .selend').val()) != '') {
        _datas.endDate = $.trim($('.selDatebooking .selend').val())
    }
    baseFn.objDelElm(bookerDTdata, 'limit')
    for (var i in _datas) {
        bookerDTdata[i] = _datas[i]
    }
    bookerDT.ajax.reload();
}
$('.js_bookingstatus').val(4)
$('.js_bookingstatus').on('change', function () {
    searchBooking()
})
//时间控件初始化
//就诊记录
baseFn.dateTimePickGroup('.selDatepatient', {
    startseled: function () {
        searchPatient()
    },
    endseled: function () {
        searchPatient()
    }
})
//收费信息
baseFn.dateTimePickGroup('.selDateorder', {
    startseled: function () {
        searchOrder()
    },
    endseled: function () {
        searchOrder()
    }
})
//预约信息
baseFn.dateTimePickGroup('.selDatebooking', {
    startseled: function () {
        searchBooking()
    },
    endseled: function () {
        searchBooking()
    }
})
/*病人详情 */

// selectSysList
var selectSysList = {};
var totalSpecialScore = 0;

var patientData = {
    initVipBase: function (data) {
        var _userData = data
        if (baseFn.notNull(_userData.userName)) {
            $('.js_userName').text(_userData.userName)
        } else {
            $('.js_userName').text('无会员名')
        }

        $('.userLevel').text(_userData.userLevel)
        $('.userPhone').text(baseFn.getHidePhoneStr(_userData.userPhone))
        $('.userGender').text(_userData.userGender == 0 ? '男' : '女')
        $('.js_userAccount').text(_userData.userAccount)
        $('.js_cardCount').text(_userData.cardCount)
        $('.js_couponCount').text(_userData.couponCount)
        $('.js_orderCost').text(_userData.orderCost)
        $('.js_createTime').text(_userData.createTimeStr)
        $('.js_userImg').css('background-img', 'url(' + _userData.userImg + ')')
        /**
         * userAccount：储值余额
         cardCount：卡项
         couponCount：优惠券
         orderCost：订单金额
         userGender：性别
         */
    },
    doctorId: "1",//使用后台的人 之后再改
    baseData: {},
    historyData: {},
    initBase: function (data) {
        //基本信息
        var _baseData = data;
        $('.patientName').val(_baseData.patientName)
        $('select.patientGender').val(_baseData.patientGender)
        $('.patientBirthday').val(_baseData.patientBirthday)
        $('.patientAddress').val(_baseData.patientAddress)
        $('.patientBodyWeight').val(_baseData.patientBodyWeight)
        $('.patientHeight').val(_baseData.patientHeight)
        // $('.userTimes').val(_baseData.patientTime?_baseData.patientTime:'无')
        $('.userTimes').text(baseFn.notNull(_baseData.patientTime) ? baseFn.timestampToTime(_baseData.patientTime) : '无')
        $('p.patientName,span.js_patientName').text(_baseData.patientName)
        $('p.patientGender,span.js_patientGender,em.js_patientGender').text(_baseData.patientGender == 0 ? '男' : '女')
        $('p.patientBirthday').text(_baseData.patientBirthday)
        $('p.patientAddress,span.js_patientAddress').text(_baseData.patientAddress)
        $('p.userSource').text(_baseData.userSource)
        $('span.patientBodyWeight').text(_baseData.patientBodyWeight)
        $('span.patientHeight').text(_baseData.patientHeight)
        $('p.js_patientDesc').text(_baseData.patientDesc)
        $('span.js_patientAge').text(_baseData.patientAge)
        // var _userSource = ''
        // if(_baseData.userSource == '0'){
        //     _userSource = '线下'
        // }else if(_baseData.userSource == '1'){
        //     _userSource = '线上'
        // }
        // $('select.userSource').val(_baseData.userSource)
        $('input.userSource').val(_baseData.userSource)
        if (_baseData.patientImg != '' && _baseData.patientImg != null && _baseData.patientImg != undefined) {
            $('.js_patientImg').css('background-image', 'url(' + _baseData.patientImg + ')')
            baseFn.imgSize({
                src: _baseData.patientImg,
                hFn: function (res) {
                    res.dom.css({'background-size': 'auto 100%'})
                },
                wFn: function (res) {
                    res.dom.css({'background-size': '100% auto'})
                },
                ratio: 1,
                otherData: {
                    dom: $('.js_patientImg')
                }
            })
            $('.imghead').attr('src', _baseData.patientImg)
            $('input.Js_imgUrl').val(_baseData.patientImg)
            this.imgChange = true
        } else {
            $('.js_patientImg').css('background-image', 'url(' + baseUrl.patientImg + ')')
        }

    },
    initHistory: function (data) {
        //既往病史档案
        var _phisData = data
        $('.allergyHistory').val(_phisData.allergyHistory)//过敏史
        $('.userHistory').val(_phisData.userHistory)//个人病史
        $('.feverHistory').val(_phisData.feverHistory)//高烧惊厥史
        $('.medicineHistory').val(_phisData.medicineHistory)//用药史
        $('.laboratoryHistory').val(_phisData.laboratoryHistory)//实验室辅助检查
    },
    initHomeCase: function (opts) {
        //家庭护理环境生成
        var _homecareTxt = "", _homecareData = opts.data
        if (_homecareData.length == 0) {
            $('.homecareno').removeClass('hidden')
            $('.homecaremaincnt').addClass('hidden')
            $('.card.homecarecard').addClass('hidden')
        } else {
            $('.homecaremaincnt').removeClass('hidden')
            $('.homecareno').addClass('hidden')
            $('.homecaredate>span').text(opts.date == null ? '无' : baseFn.timestampToTime(opts.date))
            var _score = 0
            for (var h1 = 0; h1 < _homecareData.length; h1 += 2) {
                _homecareTxt += '<div class="rows"><p class="cols10" style="margin-bottom:0;padding-left:10px;padding-right:10px">'
                _homecareTxt += '<span class="font_bold">' + _homecareData[h1].typeName + ' ：</span>' + _homecareData[h1].nursingName
                _homecareTxt += '</p>'
                _score += Number(_homecareData[h1].nursingValue)

                if (_homecareData[h1 + 1]) {
                    _homecareTxt += '<p class="cols10" style="margin-bottom:0;padding-left:10px;padding-right:10px">'
                    _homecareTxt += '<span class="font_bold">' + _homecareData[h1 + 1].typeName + ' ：</span>' + _homecareData[h1 + 1].nursingName
                    _homecareTxt += '</p>'
                    _score += Number(_homecareData[h1 + 1].nursingValue)
                }
                _homecareTxt += '</div>'
            }
            $('.homecarescore span').html(_score)
            $('.card.homecarecard').removeClass('hidden')
            $('.card.homecarecard').html(_homecareTxt)
        }

    },
    initCaseList: function (data) {
        $.get(baseUrl.base + baseUrl.patient + 'selectHistoryTreatmentList', {patientId: patientData.patientId}, function (res) {
            var _caselistmainTxt = "", _caselistPopTxt = "";
            if (res.code == "0") {
                if (res.results.length == 0) {
                    _caselistmainTxt = '<div class="cols20 rows zcformelm" style="padding-left:19px"><p>暂无数据</p></div>'
                    $('.treatlistwrap.caselist').html(_caselistmainTxt)
                    $('.js_caselistmore').addClass('hidden')

                } else {

                    for (var h2 = 0; h2 < res.results.length; h2++) {
                        _caselistPopTxt += '<a href="javascript:void(0)" data-vals="' + res.results[h2].treatmentId + '" class="rows caselistelm2"><span class="cols3"></span>\
                            <span class="cols10 font_3d">' + baseFn.timestampToTime(res.results[h2].treatmentTime) + '</span>\
                            <span class="cols4 font_3d font_right">' + res.results[h2].userName + '</span><span class="cols3"></span>\
                        </a>'
                        if (h2 < 3) {
                            _caselistmainTxt += '<div class="cols20 rows zcformelm">\
                                        <a href="javascript:void(0)" data-vals="' + res.results[h2].treatmentId + '" class="font_blue caselistelm" style="padding-left:19px">' + baseFn.timestampToTime(res.results[h2].treatmentTime) + ' ' + res.results[h2].userName + ' </a>\
                                </div>'
                        }
                    }
                    $('.dialogelm.caselist').find('.card.list').html(_caselistPopTxt)
                    $('.treatlistwrap .caselist').html(_caselistmainTxt)
                    $('.js_caselistmore').removeClass('hidden')
                }
            }
        }, 'json')
    },
    initCaseDetail: function (data) {
        var _data = data
        $.get(baseUrl.base + baseUrl.patient + 'selectSysTreatmentInfo', {
            treatmentId: _data.treatmentId,
            isOld: 1
        }, function (res) {
            var _popWrap = $(_data.domName)
            if (res.code == '0') {
                var _caseDetail = res.results,
                    _visit = _data.visitData,//就诊基本信息
                    _base = _caseDetail.patientTreatment,//基础信息
                    _disease = _caseDetail.diseaseRelList,//兼/主症描述
                    _point = _caseDetail.pointList,//配穴
                    _conclusion = _caseDetail.conclusionList,
                    _specialMap = _caseDetail.treatmentSpecialMap,
                    _infoIds = _specialMap.infoIds;
                var _diseaseTxt = '', _mainDiseaseTxt = "", _specialDiseaseTxt = "", _pointTxt = "",
                    _conclusionTxt = "", _imgTxt = "";
                for (var i = 0; i < _disease.length; i++) {
                    if (_disease[i].diseaseName == "正常" || _disease[i].diseaseName == "无" || _disease[i].diseaseName == "") {
                        continue; // 过滤掉正常项目
                    }
                    if (_disease[i].isMain == '1') {
                        _mainDiseaseTxt += '<li>' + _disease[i].typeName + '：' + _disease[i].diseaseName + '</li>'
                    } else {
                        _diseaseTxt += '<li>' + _disease[i].typeName + '：' + _disease[i].diseaseName + '</li>'
                    }
                }

                if (_infoIds.length == 0) {
                    _specialDiseaseTxt += '<li>无</li>'
                } else {
                    _specialDiseaseTxt += '<li>腺样体专病</li>'
                }
                for (var i = 0; i < _infoIds.length; i++) {
                    var specialList = selectSysList.specialList;
                    for (var j = 0; j < specialList.length; j++) {
                        if (specialList[j].infoId == _infoIds[i]) {
                            _specialDiseaseTxt += '<li>' + specialList[j].infoName + '</li>'
                        }
                    }
                }
                _specialDiseaseTxt += '<br>'
                _specialDiseaseTxt += '<li>预估评分结果：<span id="s1_' + data.treatmentId + '">' + _specialMap.specialCheckScore + '</span>%</li>'
                _specialDiseaseTxt += '<li>鼻腔镜检查结果：<span id="s2_' + data.treatmentId + '">' + _specialMap.specialRealScore + '</span>%  ';
                if (!baseFn.getPower(81)) {
                    _specialDiseaseTxt += '<a href="javascript:clickEditReal(\'editReal_' + data.treatmentId + '\')" id="editReal_' + data.treatmentId + '" class="font_blue js_power_81" treatmentId="' + _data.treatmentId + '">编辑</a>';
                }
                _specialDiseaseTxt += '</li>'
                _specialDiseaseTxt += '<li>误差：<span id="s3_' + data.treatmentId + '">' + _specialMap.specialError + '</span>%</li>'

                if (_point.length == 0) {
                    _pointTxt = '无'
                }
                for (var j = 0; j < _point.length; j++) {
                    _pointTxt += '<li>' + _point[j].typeName + '：' + _point[j].pointName + '</li>'
                }
                for (var k = 0; k < _conclusion.length; k++) {
                    _conclusionTxt += '<span> ' + _conclusion[k].conclusionName + ' </span>'
                }
                $('.diseaseRelList').html(_diseaseTxt)
                $('.mainDiseaseRelList').html(_mainDiseaseTxt)
                $('.pointRelList').html(_pointTxt)
                $('.conclusionList').html(_conclusionTxt)
                $('.specialDiseaseRelList').html(_specialDiseaseTxt)

                $('.subclinicName').text(_visit.subclinicName)
                $('.visitTimeStr').text(_visit.orderTime)
                $('.doctorName').text(_visit.doctorName)
                $('.diseaseInfo').text(_base.diseaseInfo)
                $('.diseaseTime').text(baseFn.timestampToTime(_base.diseaseTime).substring(0, 10))
                $('.treatmentRemarks').text(_base.treatmentRemarks)
                if (_base.treatmentImg && baseFn.notNull(_base.treatmentImg)) {
                    var _img = _base.treatmentImg.split(';'), _imgTxt = ''
                    for (var m = 0; m < _img.length; m++) {
                        _imgTxt += '<a href="javascript:void(0)" class="img_wrap">\
                        <img src="' + _img[m] + '" alt="" width="100%">\
                    </a>'
                    }
                    $('.imgr1').html(_imgTxt)
                } else {
                    $('.imgr1').html('无')
                }
                if (_base.faceImg && baseFn.notNull(_base.faceImg)) {
                    var _img = _base.faceImg.split(';'), _imgTxt = ''
                    for (var m = 0; m < _img.length; m++) {
                        _imgTxt += '<a href="javascript:void(0)" class="img_wrap">\
                        <img src="' + _img[m] + '" alt="" width="100%">\
                    </a>'
                    }
                    $('.imgr2').html(_imgTxt)
                } else {
                    $('.imgr2').html('无')
                }
                if (_base.handsImg && baseFn.notNull(_base.handsImg)) {
                    var _img = _base.handsImg.split(';'), _imgTxt = ''
                    for (var m = 0; m < _img.length; m++) {
                        _imgTxt += '<a href="javascript:void(0)" class="img_wrap">\
                        <img src="' + _img[m] + '" alt="" width="100%">\
                    </a>'
                    }
                    $('.imgr3').html(_imgTxt)
                } else {
                    $('.imgr3').html('无')
                }
                if (_data.callback) {
                    _data.callback(_popWrap)
                }

            }
        }, 'json')
    },
    imgChange: false
}

// 点击编辑鼻腔镜检查结果
function clickEditReal(domId) {
    var treatmentId = $("#" + domId).attr("treatmentId");
    var checkResult = $("#s1_" + treatmentId).html();
    var realResult = $("#s2_" + treatmentId).html();
    $('#editRealInput').val(realResult);

    baseFn.dialog({
        title: '修改鼻腔镜检查结果',
        width: '25em',
        height: '15vh',
        content: $("#editRealDiv"),
        ok: function () {
            realResult = $('#editRealInput').val();
            if (!realResult || realResult == "") {
                baseFn.dialog({
                    title: '提示',
                    content: '请填写腔镜检查结果'
                })
                return;
            }

            baseFn.$post({
                url: baseUrl.patient + 'saveSpecialScore',
                data: {treatmentId: treatmentId, realResult: realResult, error: checkResult - realResult},
                canNull: true,
                calFn: function (res) {
                    baseFn.infoDialog('修改成功', function () {
                        // $("#s2_"+treatmentId).text(""+realResult+"%"); // 不好使
                        window.location.reload();
                    })
                }
            })
        }
    })
}

var caselistD = ''
var patientSel = '', bookerDT = "", orderListDT = ""
if (baseFn.getQueryString('patientId') != null && baseFn.getQueryString('userId') != null) {
    patientData.patientId = baseFn.getQueryString('patientId')
    patientData.userId = baseFn.getQueryString('userId')
    //就诊信息
    patientSel = baseFn.rpDataTables('.patientsellist', {
        ajUrl: baseUrl.base + baseUrl.patient + 'selectPatientList',
        ajDataSrc: "results",
        ajData: {
            patientId: patientData.patientId
        },
        scrollY: windowOffsetData.tableHeight(),
        autoWidth: false,
        select: false,
        columns: [
            {"data": "orderTime", width: "15%", defaultContent: ''},
            {"data": "doctorName", width: "10%", defaultContent: ''},
            {"data": "subclinicName", width: "10%", defaultContent: ''},
            {
                "data": "bookingType", defaultContent: '无', width: '10%', render: function (data, type, row, meta) {
                if (data == 0) {
                    return '调理身体'
                } else {
                    return '预防保健'
                }
            }
            },
            {
                "data": "isAdd", defaultContent: '无', width: '10%', render: function (data, type, row, meta) {
                if (data == 1 && row.bookingType == 0) {
                    return '新治疗'
                } else if (row.bookingType == 1) {
                    return '--'
                } else {
                    return '继续上次治疗'
                }
            }
            },
            {
                "data": "treatmentId", width: "10%", defaultContent: '', render: function (data, type, row, meta) {
                return "<a href='javascript:void(0)' class='font_blue caselistelm' data-vals='" + data + "'>查看病历</a>"
            }
            },
            {
                "data": "treatmentId", width: "10%", defaultContent: '', render: function (data, type, row, meta) {
                return "<a href='javascript:void(0)' class='font_blue caselistelm' data-vals='" + data + "'>查看配穴</a>"
            }
            },
            {
                "data": "treatmentList",
                width: "11%",
                defaultContent: '',
                className: 'td2p font_center',
                render: function (data, type, row, meta) {
                    var _data = data;
                    var _txt = ''
                    if (baseFn.notNull(_data)) {
                        _txt = Number(data) * 10000 / 100 + '%'

                    } else {
                        _txt = "<a href='javascript:void(0)' class='font_blue' onclick='editSel(this)'>填写随访</a>"
                    }
                    //权限管理 病人库 查看随访记录
                    if (baseFn.getPower(18)) {
                        _txt = '无权限'
                    }
                    return _txt
                }
            }
        ],
        initComplete: function () {
            $('.detail').on('click', function () {
                zcEditData('edit')
                var _id = $(this).data('vals')
            })
        },
        drawCallback: function (settings) {
            // alert( '表格重绘了' );
        },
        imgChange: false
    })
    $.get(baseUrl.base + baseUrl.patient + 'selectPatientInit', {patientId: patientData.patientId}, function (res) {
        if (res.code == '0') {
            zcEditData('edit')
            //基本信息
            patientData.baseData = res.results.patientInit
            patientData.initBase(res.results.patientInit)
            //既往病史档案
            if (baseFn.notNull(res.results.patientHistory)) {
                patientData.historyData = res.results.patientHistory
                patientData.initHistory(res.results.patientHistory)
            }

            //环境变量弹窗
            patientData.initHomeCase({
                data: res.results.nursingList,
                date: res.results.nursingDate,
                score: res.results.score
            })
            //历史病历及弹窗
            patientData.initCaseList()
        }
    }, 'json')
    //图片上传
    $('.imghead').on('click', function () {
        $('#Js_previewImgNew').trigger('click')
    })
    function zcuploadImageCover(e) {
        baseFn.imgUpload($(e).parents('form').attr('id'), function (res) {
            $(e).siblings('.Js_preview').find('img').attr('src', res.url)
            patientData.imgChange = true
            $('input[name=imgurl]').val(res.url)
        })
    }

    $.get(baseUrl.base + baseUrl.user + 'selectUserInfo', {userId: patientData.userId}, function (res) {
        if (res.code == '0') {
            patientData.initVipBase(res.results.userInfo)

        } else {
            baseFn.infoDialog(res.msg)
        }
    }, 'json')
    //收费信息
    var orderListDTdata = {
        patientId: patientData.patientId,
        limit: 10,
        orderState: 0
    }
    orderListDT = baseFn.rpDataTables('.js_orderlist', {
        ajUrl: baseUrl.base + baseUrl.order + 'selectOrderPageList',
        ajData: orderListDTdata,
        ajDataSrc: "results.rows",
        service: true,
        autoWidth: false,
        select: false,
        scrollY: windowOffsetData.tableHeight(),
        columns: [
            // {"data":null,defaultContent:'',className:'select-checkbox'},
            {
                data: "orderId",
                width: '15%',
                defaultContent: '',
                className: 'td2p',
                render: function (data, type, row, meta) {
                    if (!baseFn.notNull(row.orderNo)) {
                        row.orderNo = '无订单号'
                    }
                    if (baseFn.notNull(row.orderTime)) {
                        row.orderTime = baseFn.timestampToTime(row.orderTime)
                    } else {
                        row.orderTime = '无支付时间'
                    }
                    return '<p>订单号：' + row.orderNo + '</p><p>支付时间：' + row.orderTime + '</p>'

                }
            },
            {
                data: "orderPayCost", width: '10%', defaultContent: '无', render: function (data, type, row, meta) {
                return '￥ ' + data
            }
            },
            {
                "data": "payWay", width: '10%', defaultContent: '无', render: function (data, type, row, meta) {
                var _txt = ''
                if (row.orderState == '已关闭') {
                    data = 9
                    row.payWays = 9
                } else if (row.orderState == '待支付') {
                    data = 8;
                    row.payWays = 8
                } else if (row.orderState == '已完成') {
                    if (data == 7 || row.payWays == 7) {
                        row.payWays = 7
                        data = 7
                    }
                }
                var _payWayStrArr = ['余额', '支付宝', '微信', '现金', 'Pos机', '丁香云优惠券', '商品订单', '他人代付', '待支付', '已关闭', '无']
                var _payWayStr = baseFn.notNull2(_payWayStrArr[data], true, '其他'),
                    _payWaysStr = baseFn.notNull2(_payWayStrArr[row.payWays], true, '其他')
                _txt = _payWayStr + ' + ' + _payWaysStr
                if (_payWayStr == _payWaysStr && _payWayStr != '其他') {
                    _txt = _payWayStr
                } else if (data == 6) {
                    _txt = _payWaysStr
                } else if (_payWayStr == '其他' && _payWaysStr != '其他') {
                    _txt = _payWaysStr
                } else if (_payWayStr != '其他' && _payWaysStr == '其他') {
                    _txt = _payWayStr
                }
                return _txt
            }
            },
            {
                "data": "userName",
                width: '10%',
                defaultContent: '无',
                className: 'td2p',
                render: function (data, type, row, meta) {
                    return '<p>' + (baseFn.notNull(data) ? data : '无') + '</p><p>' + (baseFn.notNull(row.userPhone) ? baseFn.getHidePhoneStr(row.userPhone) : '无') + '</p>'
                }
            },
            {"data": "subclinicName", width: '10%', defaultContent: '无'},
            {"data": "doctorName", width: '10%', defaultContent: '无'},
            {
                "data": "orderId",
                width: '11%',
                serviceCost: '无',
                className: 'td2p',
                render: function (data, type, row, meta) {
                    var _txt = '<p>' + row.orderState + '</p>'
                    //权限管理 订单管理 - 56查看宝宝订单详情
                    if (!baseFn.getPower(56)) {
                        _txt += '<a class="font_blue js_order_btn detail" href="javascript:void(0)" data-vals="' + data + '">查看订单</a>'
                    }
                    return _txt
                }
            }
        ],
        initComplete: function () {

        },
        drawCallback: function (settings) {
            $('.js_order_btn.detail').off('click').on('click', function () {
                var _id = $(this).data('vals')
                baseFn.goPath('gotoOrderDetail', {orderId: _id, orderType: 0})
            })
        }
    })
    //预约信息
    var bookerDTdata = {
        patientId: patientData.patientId,
        userId: patientData.userId,
        bookingStatus: 4,//已完成 0待服务
        limit: 10
    }
    bookerDT = baseFn.rpDataTables('.booking_list', {
        ajUrl: baseUrl.base + baseUrl.booking + 'selectBookingPageList',
        ajDataSrc: "results.rows",
        ajData: bookerDTdata,
        service: true,
        select: true,
        scrollY: windowOffsetData.tableHeight(),
        ajType: 'get',
        autoWidth: false,
        columns: [
            {"data": "subclinicName", defaultContent: '', width: '10%'},
            {"data": "doctorName", defaultContent: '无', width: '10%'},
            {
                "data": "bookingType", defaultContent: '无', width: '10%', render: function (data, type, row, meta) {
                if (data == 0) {
                    return '调理身体'
                } else {
                    return '预防保健'
                }
            }
            },
            {
                "data": "isAdd", defaultContent: '无', width: '10%', render: function (data, type, row, meta) {
                if (data == 1 && row.bookingType == 0) {
                    return '新治疗'
                } else if (row.bookingType == 1) {
                    return '--'
                } else {
                    return '继续上次治疗'
                }
            }
            },
            {
                "data": "bookingTime", defaultContent: '无', width: '12%',
                render: function (data, type, row, meta) {
                    if (!data) {
                        return "无";
                    } else {
                        return baseFn.timestampToTime(data);
                    }

                }
            },
            {"data": "bookingDesc", defaultContent: '无', width: '10%'},
            {
                "data": null,
                defaultContent: '无',
                width: '10%',
                className: "td2p",
                render: function (data, type, row, meta) {
                    //状态:0:待服务;1:已超时;2:调理中;3:待支付;4:已完成;5:取消
                    if (row.bookingStatus == 0) {
                        //待服务
                        var _txt = '<button type="button" class="datatablebtn datatablebtnGray" data-vals="' + data + '" onclick="cancelBtn(this)" rel="true">取消</button>\
                        <button type="button" class="datatablebtn datatablebtnRed" data-vals="' + data + '" onclick="updateBtn(this)">更改</button>'

                        //权限控制 预约管理-接诊
                        if (!baseFn.getPower(11)) {
                            _txt += '<a class="datatablebtn" href="' + baseUrl.base + 'order/gotoFastOrder?bookingId=' + row.bookingId + '&userPhone=' + row.userPhone + '&userId=' + row.userId + '" data-vals="' + data + '">接诊</a>';
                        }
                        return _txt;

                    } else if (row.bookingStatus == 5) {
                        //已取消
                        return '<p>已取消</p>\
                        <p>取消时间：' + row.cancelTime + '</p>';
                    } else if (row.bookingStatus == 4) {
                        //已完成
                        if (row.treatmentState == 1) {
                            return '<p>已完成</p>';
                        } else {
                            return '<p>待完善</p>';
                        }
                    } else if (row.bookingStatus == 3) {
                        //待支付
                        return '\
                        <button type="button" class="datatablebtn datatablebtnGray" data-vals="' + data + '" onclick="cancelBtn(this)" rel="true">取消</button>\
                        <button class="datatablebtn" data-vals="' + data + '"><a class="tableNewBtnBlue" href="javascript:void(0)" onclick="square(this)">结账</a></button>';
                    } else if (row.bookingStatus == 2) {
                        //调理中
                        return '<p>调理中</p>';
                    } else if (row.bookingStatus == 1) {
                        //已超时
                        return '\
                        <button type="button" class="datatablebtn datatablebtnGray" data-vals="' + data + '" onclick="cancelBtn(this)"  rel="true">取消</button>\
                        <button type="button" class="datatablebtn datatablebtnRed" data-vals="' + data + '" onclick="updateBtn(this)" >更改</button>\
                        <a class="datatablebtn" href="' + baseUrl.base + 'order/gotoFastOrder?bookingId=' + row.bookingId + '&userPhone=' + row.userPhone + '&userId=' + row.userId + '" data-vals="' + data + '">接诊</a>';
                    } else if (row.bookingStatus == 6) {
                        //已接诊
                        var _patient = ''
                        if (baseFn.notNull(row.patientId)) {
                            _patient = '&patientId=' + row.patientId
                        }
                        return '\
                        <button type="button" class="datatablebtn datatablebtnGray" data-vals="' + data + '" onclick="cancelBtn(this)" rel="true">取消</button>\
                        <a class="datatablebtn" href="' + baseUrl.base + 'order/gotoFastOrder?bookingId=' + row.bookingId + '&userPhone=' + row.userPhone + '&userId=' + row.userId + '&subclinicId=' + row.subclinicId + '&doctorId=' + row.doctorId + _patient + '" data-vals="' + data + '">继续</a>';
                    } else {
                        if (row.cancelType == 2) {
                            return '<p style="line-height: 1.5rem;">商家已取消</p>\
                                <p style="line-height: 1.5rem;">取消时间：' + row.cancelTime + '</p>';
                        } else {
                            return '<p style="line-height: 1.5rem;">用户已取消</p>\
                                <p style="line-height: 1.5rem;">取消时间：' + row.cancelTime + '</p>';
                        }
                    }
                }
            }
        ],
        initComplete: function () {
        },
        drawCallback: function (settings) {
            // alert( '表格重绘了' );
        }
    })
    //随访记录生成
    baseFn.$get({
        url: baseUrl.init + 'selectSysList',
        data: {},
        calFn: function (res) {
            selectSysList = res;
            for (var i = 0; i < selectSysList.specialList.length; i++) {
                var specialObj = selectSysList.specialList[i];
                totalSpecialScore += parseInt(specialObj.scroe);
            }
            var _data = res.diseaseList;
            var _phonealltxt = "";
            for (var i = 0; i < _data.length; i++) {
                if (_data[i].isMain == 1) {
                    //获取主症（随访记录数据）
                    var phonecall = _data[i];
                    _phonealltxt += '<div class="rows nopd zcformelm"><div class="cols4"><p class="zcform_text">' + (i + 1) + '. ' + phonecall.typeName + '： </p></div><div class="cols15 zcformelm" style="padding-left:0.8rem">'
                    _phonealltxt += "<select class='zcform_select select_arrow' data-vals='" + phonecall.typeId + "," + phonecall.typeName + "'>"
                    for (var z = 0; z < phonecall.childList.length; z++) {
                        _phonealltxt += "<option value='" + phonecall.childList[z].descId + "," + phonecall.childList[z].descName + "," + phonecall.childList[z].diseaseScore + "' >" + phonecall.childList[z].descName + "</option>"
                    }
                    _phonealltxt += "</select></div></div>"
                }
            }
            $('.dialogelm.phonecall .zccard').html(_phonealltxt)
        }
    })
}
;

//家庭护理环境
$('.homecarebtn').on('click', function () {
    var homecareD = baseFn.dialog({
        title: '家庭护理环境',
        width: '60em',
        height: "70vh",
        content: $('.dialogelm.homecare'),
        ok: false
    })

})
var myValidform = $(".dialogelm.base").Validform({
    tiptype: 3
});
//病人基本信息弹窗
$('.infoedit.base').on('click', function () {
    var baseD = baseFn.dialog({
        title: '基本档案',
        width: '30em',
        content: $('.dialogelm.base'),
        ok: false
    })
    //取消
    $('.dialogelm.base .buttongroup .edit_cancel').off('click').on('click', function () {
        patientData.initBase(patientData.baseData)
        baseD.close()
    })
    //确定
    $('.dialogelm.base .buttongroup .edit_ok').off('click').on('click', function () {
        // $('.dialogelm.base .buttongroup .edit_ing').addClass('hidden')
        if (!myValidform.check()) {
            return false
        }
        var _upDatas = {
            patientId: patientData.patientId,
            // patientId:patientData.patientId,
            userName: $('.dialogelm.base .patientName').val(),
            userGender: $('.dialogelm.base select.patientGender').val(),
            userBirthday: $('.dialogelm.base .patientBirthday').val(),
            userAddress: $('.dialogelm.base .patientAddress').val(),
            userBodyWeight: $('.dialogelm.base .patientBodyWeight').val(),
            userHeight: $('.dialogelm.base .patientHeight').val(),
            userSource: $('.dialogelm.base input.userSource').val()
        }
        if (patientData.imgChange) {
            _upDatas.userImg = $('input[name=imgurl]').val()
        }

        $.post(baseUrl.base + baseUrl.patient + 'updatePatientInit', _upDatas, function (res) {
            if (res.code == '0') {
                patientData.baseData = {
                    patientId: patientData.patientId,
                    patientName: $('.dialogelm.base .patientName').val(),
                    patientGender: $('.dialogelm.base select.patientGender').val(),
                    patientBirthday: $('.dialogelm.base .patientBirthday').val(),
                    patientAddress: $('.dialogelm.base .patientAddress').val(),
                    patientBodyWeight: $('.dialogelm.base .patientBodyWeight').val(),
                    patientHeight: $('.dialogelm.base .patientHeight').val(),
                    userSource: $('.dialogelm.base input.userSource').val(),
                    patientImg: $('input[name=imgurl]').val()
                }
                patientData.initBase(patientData.baseData)
                baseFn.infoDialog(res.msg, function () {
                }, 1000)
                baseD.close()
            }
        }, 'json')

    })
})
baseFn.dateTimePick('.patientBirthday', {})
//病史弹窗
$('.infoedit.phistory,.infoedit.phistoryex').on('click', function () {
    var phistoryD = baseFn.dialog({
        title: '既往病史档案',
        width: '40em',
        content: $('.dialogelm.phistory'),
        height: '70vh',
        ok: false
    })
    //取消
    $('.dialogelm.phistory .buttongroup .edit_cancel').off('click').on('click', function () {
        patientData.initHistory(patientData.historyData)
        phistoryD.close()
    })
    //确定
    $('.dialogelm.phistory .buttongroup .edit_ok').off('click').on('click', function () {
        var _upDatas = {
            patientId: patientData.patientId,
            allergyHistory: $('.dialogelm.phistory .allergyHistory').val(),
            userHistory: $('.dialogelm.phistory .userHistory').val(),
            feverHistory: $('.dialogelm.phistory .feverHistory').val(),
            medicineHistory: $('.dialogelm.phistory .medicineHistory').val(),
            laboratoryHistory: $('.dialogelm.phistory .laboratoryHistory').val()
        }
        $.post(baseUrl.base + baseUrl.patient + 'updatePatientHistory', _upDatas, function (res) {
            if (res.code == '0') {
                patientData.historyData = _upDatas
                patientData.initHistory(patientData.historyData)
                baseFn.infoDialog(res.msg, function () {
                }, 1000)
                $('.dialogelm.phistory').find('textarea.zcform_textarea').prop('readonly', true)
                phistoryD.close()
            }

        }, 'json')

    })
    //编辑
    $('.dialogelm.phistory .buttongroup .edit_ing').off('click').on('click', function () {
        $('.dialogelm.phistory .buttongroup .edit_ing').addClass('hidden')
        $('.dialogelm.phistory .buttongroup .edit_ok').removeClass('hidden')
        $('.dialogelm.phistory .buttongroup .edit_cancel').removeClass('hidden')

        $('.dialogelm.phistory').find('textarea.zcform_textarea').prop('readonly', false)
    })

    if ($(this).hasClass('phistoryex')) {
        //展开
        $('.dialogelm.phistory .buttongroup .edit_ing').removeClass('hidden')
        $('.dialogelm.phistory .buttongroup .edit_ok').addClass('hidden')
        $('.dialogelm.phistory .buttongroup .edit_cancel').addClass('hidden')
        $('.dialogelm.phistory').find('textarea.zcform_textarea').prop('readonly', true)
    } else {
        //编辑
        $('.dialogelm.phistory .buttongroup .edit_ing').trigger('click')
    }
})

//病人病历详情弹窗
$(document).on('click', '.caselistelm', function () {
    var _treatmentId = $(this).data('vals')
    var _visitData = patientSel.row($(this).parents('tr')).data()
    patientData.initCaseDetail({
        domName: '.dialogelm.casedetail',
        treatmentId: _treatmentId,
        visitData: _visitData,
        callback: function (content) {
            var baseD = baseFn.dialog({
                title: '病历详情',
                width: '40em',
                height: '70vh',
                content: content,
                ok: false
            })
        }
    })

})
//电话随访
function editSel(e) {
    $('.dialogelm.phonecall .zcform_select').each(function (i, val) {
        $(val).val($(val).find('option:eq(0)').val())
    })
    var _data = patientSel.row($(e).parents('tr')).data()
    var phonecallD = baseFn.dialog({
        title: '电话随访',
        width: '40em',
        height: "70vh",
        content: $('.dialogelm.phonecall'),
        ok: false
    })
    $('.dialogelm.phonecall .edit_ok').off('click').on('click', function () {
        var _upDatas = {
            // treatmentId:'',
            // bookingId:'',
            // userId:'',
            // patientId:'',
            // doctorId:'',
            diseaseArray: []
        }
        $('.dialogelm.phonecall .zcform_select').each(function (i, val) {

            var $this = $(val);
            var _Types = $this.data('vals').split(','), _Disease = $this.val().split(',')
            var _temp = {
                treatmentId: _data.treatmentId,
                bookingId: _data.bookingId,
                userId: Number(patientData.userId),
                patientId: _data.patientId,
                doctorId: _data.doctorId,
                typeId: _Types[0],
                typeName: _Types[1],
                diseaseId: _Disease[0],
                diseaseName: _Disease[1],
                diseaseScore: _Disease[2]
            }
            _upDatas.diseaseArray.push(_temp)
        })
        _upDatas.diseaseArray = JSON.stringify(_upDatas.diseaseArray);
        $.post(baseUrl.base + baseUrl.patient + 'saveDiseaseList', _upDatas, function (res) {
            if (res.code == '0') {
                baseFn.infoDialog('提交成功')
                phonecallD.close()
                $('.dialogelm.phonecall .zcform_select').each(function (i, val) {
                    $(val).val($(val).find('option:eq(0)').val())

                })
                patientSel.ajax.reload(null, false)
            } else {
                baseFn.infoDialog(res.msg)
            }
        }, 'json')

    })
}
/*病人库列表*/
var patientsDTdata = {
    subclinicId: SessionData.powerSub ? SessionData.powerSub : 0,//权限管理 45 全部门店?
    // subclinicId:0,//权限管理 45 全部门店?
    fromPage: '0',
    // page: 1,
    timeType: 0,
    numberStart: 0,
    userPhone: "",
    numberEnd: 999999,
    limit: 10
}
var patientsDTFnData = {
    ajUrl: baseUrl.base + baseUrl.patient + 'selectSysPatientList',
    ajDataSrc: "results.rows",
    ajData: patientsDTdata,
    sessionPageKey: "patientPage",
    select: false,
    scrollY: windowOffsetData.tableHeight(),
    autoWidth: false,
    service: true,
    columns: [
        // {"data":null,defaultContent:'',className:'select-checkbox'},
        {
            "data": "patientName",
            defaultContent: '',
            width: '15%',
            className: 'imgpwrap img2p',
            render: function (data, type, row, meta) {
                var sex = ['男', '女']
                if (data == undefined) {
                    data = '宝宝'
                }
                if (row.patientGender == undefined) {
                    row.patientGender = 0
                }
                var _img = baseUrl.patientImg
                if (baseFn.notNull(row.patientImg)) {
                    _img = row.patientImg
                }
                return '<div class="datatable_img_div" data-vals="' + _img + '" style="background-image:url(' + _img + ')"></div>\
                    <div class="pwrap">\
                        <span>' + data + '</span>\
                        <span>' + sex[row.patientGender] + row.patientAge + '岁</span>\
                    </div>'
            }
        },
        {
            "data": "userName",
            defaultContent: '',
            width: '15%',
            className: 'imgpwrap',
            render: function (data, type, row, meta) {
                if (data == undefined) {
                    data = '无关联会员'
                }
                // if (baseFn.notNull(row.userPhone)) {
                //     row.userPhone = '无手机号'
                // }
                var _img = baseUrl.tempHeadImg
                if (baseFn.notNull(row.userImg)) {
                    _img = row.userImg
                }
                // return '<img class="bespeak_change_img" src="'+row.userImg+'">
                return '<div class="datatable_img_div" data-vals="' + _img + '" style="background-image:url(' + _img + ')"></div>\
                    <div class="pwrap">\
                        <span><a href="javascript:void(0)" class="font_blue js_goods_btn vipdetail" data-vals="' + row.userId + '">' + data + '</a></span>\
                        <span>' + baseFn.getHidePhoneStr(row.userPhone) + '</span>\
                        <span>次卡张数：' + row.cardNum + '</span>\
                    </div>'
            }
        },
        {"data": "orderNumber", width: '10%', defaultContent: ''},
        {"data": "subclinicName", width: '20%', defaultContent: '无'},
        {"data": "lastTime", width: '20%', defaultContent: '无'},
        {
            "data": "patientId",
            width: '10%',
            defaultContent: '',
            className: "userlib6",
            render: function (data, type, row, meta) {
                // var _txt = '<a class="datatablebtn detail" href="/xrtn-manager/patient/gotoPatientInfo?patientId=' + data + '&userId=' + row.userId + '" data-vals="' + data + ',' + row.userId + '" >详情</a>'
                var _txt = '<button class="datatablebtn detail" data-vals="' + data + ',' + row.userId + '">详情</button>';
                if (!baseFn.getPower(77)) {
                    _txt += '<button class="datatablebtn datatablebtnGray del" data-vals="' + data + '">删除</button>'
                }
                return _txt;
            }
        }

    ],
    initComplete: function () {
    },
    page: function () {
        // $.session.set(this.sessionPageKey, patientsDT.page()+1);
    },
    drawCallback: function (settings) {
        //图片初始化
        $('.datatable_img_div').each(function (ids, val) {
            baseFn.imgSize({
                src: $(val).data('vals'),
                hFn: function (res) {
                    res.dom.css({'background-size': 'auto 100%'})
                },
                wFn: function (res) {
                    res.dom.css({'background-size': '100% auto'})
                },
                ratio: 1,
                otherData: {
                    dom: $(val)
                }
            })
        })

        $('.detail').off('click').on('click', function () {
            var patientId = $(this).data('vals').split(",")[0];
            var userId = $(this).data('vals').split(",")[1];
            baseFn.goPath('gotoPatientInfo', {patientId: patientId, userId: userId})
        })
        $('.del').off('click').on('click', function () {
            var patientId = $(this).data('vals');
            var _tr = $(this).parents('tr')
            baseFn.dialog({
                title: '确定删除该宝宝么？',
                content: '若该宝宝没有已完成订单，将删除该宝宝下的预约记录等相关信息。否则将无法删除。',
                ok: function () {
                    baseFn.$post({
                        url: baseUrl.patient + 'deletePatientInfo',
                        data: {patientId: patientId},
                        canNull: true,
                        calFn: function (res) {
                            if (res == 0) {
                                patientsDT.row(_tr).remove().draw();
                                baseFn.infoDialog('删除成功!');
                            }
                        }
                    })
                },
                cancel: function () {
                }
            })
        })

        // vip姓名点击
        $('.js_goods_btn.vipdetail').off('click').on('click', function () {
            var _id = $(this).data('vals')
            baseFn.goPath('gotoVipDetail', {userId: _id})
        })
    }
}
//权限管理 订单管理 - 订单详情
if (baseFn.getPower(15)) {
    patientsDTFnData.columns.pop()
    $('.js_power_15').remove()
}
//病人库列表（表格）
var timeType = $.session.get("patientsTimeType") ? parseInt($.session.get("patientsTimeType")) : 0;
var numberStart = $.session.get("patientsNumberStart") ? parseInt($.session.get("patientsNumberStart")) : 0;
var numberEnd = $.session.get("patientsNumberEnd") ? parseInt($.session.get("patientsNumberEnd")) : 0;
patientsDTFnData.ajData.timeType = timeType;
patientsDTFnData.ajData.userPhone = $.session.get("patientsUserPhone");
patientsDTFnData.ajData.numberStart = numberStart;
if (numberEnd > 0) {
    patientsDTFnData.ajData.numberEnd = numberEnd;
} else {
    patientsDTFnData.ajData.numberEnd = 99999;
}
var patientsSubclinicId = $.session.get("patientsSubclinicId") ? parseInt($.session.get("patientsSubclinicId")) : patientsDTdata.subclinicId;
patientsDTFnData.ajData.subclinicId = patientsSubclinicId;


var patientsDT = baseFn.rpDataTables('.patients_list2', patientsDTFnData)
//病人库列表-右上角搜索按钮
$('.bespeak_search_button').click(function () {
    $.session.set("patientsUserPhone", $('#search').val());
    listSearchingFn.patient('.searchgroup.patientlib');
});

$("#search").keydown(function (event) {
    if (event.keyCode == "13") {
        $.session.set("patientsUserPhone", $('#search').val());
        listSearchingFn.patient('.searchgroup.patientlib');
    }
});

initializationView();

function initializationView() {
    // 时间分类
    var timeType = $.session.get("patientsTimeType") ? parseInt($.session.get("patientsTimeType")) : 0;
    switch (timeType) {
        case 0:
            $('#timeType_one').addClass('active').siblings('.searchelm').removeClass('active');
            break
        case 1:
            $('#timeType_two').addClass('active').siblings('.searchelm').removeClass('active');
            break
        case 2:
            $('#timeType_three').addClass('active').siblings('.searchelm').removeClass('active');
            break
        case 3:
            $('#timeType_four').addClass('active').siblings('.searchelm').removeClass('active');
            break
        case 4:
            $('#timeType_five').addClass('active').siblings('.searchelm').removeClass('active');
            break
    }
    // 就诊次数
    var numberStart = $.session.get("patientsNumberStart") ? parseInt($.session.get("patientsNumberStart")) : 0;
    var numberEnd = $.session.get("patientsNumberEnd") ? parseInt($.session.get("patientsNumberEnd")) : "";
    $(".js_paycount_input").val(numberStart);
    $(".js_paycount_input2").val(numberEnd);

    $('#search').val($.session.get("patientsUserPhone"));

    var patientsSubclinicName = $.session.get("patientsSubclinicName") ? ($.session.get("patientsSubclinicName")) : "全部";
}

//病人库列表-筛选条件组
$('.searchgroup.patientlib').find('.searchelm').on('click', function () {
    $(this).addClass('active').siblings('.searchelm').removeClass('active');
    var _key = $(this).parent().attr("data-vals");
    var _value = $(this).attr("data-vals");
    if (_value != undefined) {
        $.session.set("patientPage", 1);
        $.session.set("patientsTimeType", _value ? _value : 0);
    }
    listSearchingFn.patient('.searchgroup.patientlib');
})
//病人库列表-筛选条件组-获客门店
baseFn.rpSelect('.subclinicselect', {
    url: baseUrl.base + baseUrl.subclinic + 'selectSubclinicList',
    idKey: 'subclinicId',
    textKey: 'subclinicName',
    calFn: function (dom) {
        //权限管理 45 全部门店
        if (SessionData.powerSub) {
            dom.val(SessionData.powerSub).trigger('change')
        }
        dom.val(patientsSubclinicId).trigger('change')
    },
    selFn: function () {
        listSearchingFn.patient('.searchgroup.patientlib');
        $.session.set("patientsSubclinicId", $('.subclinicselect').val());
        $.session.set("patientsSubclinicName", $('.subclinicselect option:selected').text());
    }
})
//病人库列表-筛选条件组-就诊次数
$('.js_paycount_input,.js_paycount_input2').on('change', function () {
    listSearchingFn.patient('.searchgroup.patientlib');
    $.session.set("patientsNumberStart", $('.js_paycount_input').val());
    $.session.set("patientsNumberEnd", $('.js_paycount_input2').val());
})
$('.js_out_patient_btn').on('click', function () {//导出宝宝
    var _data = listSearchingFn.patient('.searchgroup.patientlib', true), upData = {
        numberStart: _data.numberStart,
        timeType: _data.timeType
    };
    if (baseFn.notNull(_data.numberEnd)) {
        upData.numberEnd = _data.numberEnd
    }
    if (_data.subclinicId != 0) {
        upData.subclinicId = _data.subclinicId
    }
    $(this).attr('href', baseFn.goPath('exportPatientList', upData, 'urlData'))
})
$('.js_out_treatment_btn').on('click', function () {//导出病历
    var _data = listSearchingFn.patient('.searchgroup.patientlib', true), upData = {
        numberStart: _data.numberStart,
        timeType: _data.timeType
    };
    if (baseFn.notNull(_data.numberEnd)) {
        upData.numberEnd = _data.numberEnd
    }
    if (_data.subclinicId != 0) {
        upData.subclinicId = _data.subclinicId
    }
    $(this).attr('href', baseFn.goPath('exportTreatmentList', upData, 'urlData'))
})
/*病人库列表*/
//复选框
$(document).on('click', 'input[type=checkbox].checkbox', function () {
    if ($(this).hasClass('checkBox_checked')) {
        $(this).removeClass("checkBox_checked");
    } else {
        $(this).addClass('checkBox_checked')
    }
})
window.onresize = function () {
    windowOffsetData.refresh();
    $(patientsDT.table().body()).parents('.dataTables_scrollBody').css('max-height', windowOffsetData.tableHeight(1));
    patientsDT.draw(false);

}
$('.js_tabcnt').css('height', windowOffsetData.tableHeight() + 130)
//表格自适应
window.onresize = function () {
    windowOffsetData.refresh();
    $('.js_tabcnt').css('height', windowOffsetData.tableHeight() + 130)
    $(patientsDT.table().body()).parents('.dataTables_scrollBody').css('max-height', windowOffsetData.tableHeight());
    patientsDT.draw(false);
    //收费
    if (baseFn.notNull(orderListDT)) {
        $(orderListDT.table().body()).parents('.dataTables_scrollBody').css('max-height', windowOffsetData.tableHeight());
        orderListDT.draw(false);
    }
    //预约
    if (baseFn.notNull(bookerDT)) {
        $(bookerDT.table().body()).parents('.dataTables_scrollBody').css('max-height', windowOffsetData.tableHeight());
        bookerDT.draw(false);
    }
    //就诊信息

    if (baseFn.notNull(patientSel)) {
        $(patientSel.table().body()).parents('.dataTables_scrollBody').css('max-height', windowOffsetData.tableHeight());
        patientSel.draw(false);
    }


}
